<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title><?php echo C("SITE_NAME");?>管理后台</title>
<link rel="shortcut icon" href=" /favicon.ico" />
<link rel="stylesheet" href="/Static/admin/css/component-min.css">
<link rel="stylesheet" href="/Static/admin/css/home.2015.05.22-09.32.css">
<link rel="stylesheet" href="/Static/admin/icon/iconfont.css">
<!--弹窗-->
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script src="/Static/admin/js/layer-2.x/layer.js?v=1.9.0"></script>
<script src="/Static/admin/js/common.js"></script>
<script>
	var UPYUN_DOMAIN = '<?php echo C("UPYUN_DOMAIN");?>';
</script>
</head>
<body class="cp-bodybox">
<!--[if lt IE 9]>
<div class="alert alert-danger disable-del txtCenter" id="tipLowIEVer">
    <h4>系统检测到您使用的浏览器版本过低，为达到更好的体验效果请升级您的浏览器，我们为您推荐：</h4>
    <p>
        <a href="http://www.firefox.com.cn/download/" target="_blank">Firefox浏览器</a>
        <a href="http://www.maxthon.cn/" target="_blank">遨游浏览器</a>
        <a href="http://se.360.cn/" target="_blank">360浏览器</a>
    </p>
</div>
<![endif]-->
<style>
.header-nav-list a {
  display: block;
  padding: 0 10px;
  min-width: 70px;
  line-height: 53px;
  font-size: 14px;
  text-align: center;
  font-weight: 700;
}
</style>

<div class="header">
    <div class="inner clearfix">
        <div class="fl">
            <a href="/" class="header-logo">
                <img
                    src="<?php echo C('UPYUN_DOMAIN'); echo C('SITE_TOPLOGO2');?>"
                    onerror="javascript:this.src='/Static/admin/images/error.png';"
                    ></a>
        </div>
        <!-- end logo -->

        <div class="header-nav fl">
            <ul class="header-nav-list clearfix">
                <!--<li class="fl <?php echo ($controller == 'index')?'active':'';?>"><a href="/admin">首页</a></li>-->
                <?php foreach($MENU as $k=>$v){?>
                <li class="fl <?php echo ($controller == $v['controller'])?'active':'';?>">
                    <a href="<?php echo $v['url'];?>"><?php echo $v['title'];?></a>
                </li>
                <?php } ?>
            </ul>
        </div>
        <!-- end header-nav -->

        <div class="fr">
            <ul class="header-ctrl clearfix">
                <li class="header-ctrl-item fl"><a href="/admin/login/logout">退出</a></li>
            </ul>
        </div>

        <span class="account_inbox_switch fr"></span>
        <span class="header-welcome fr">
            <a href="javasecript:;" class="tips" data-trigger="hover" data-placement="top"><?php echo $admininfo['username'];?></a>
        </span>

    </div>
</div>
<!-- end header -->
	<div class="container">
		<div class="inner clearfix">
	<div class="content-left fl">
    <?php foreach($SUBMENU as $subkey=>$sub){ ?>
    <dl class="left-menu shop_8">
        <dt>
            <i class="icon-menu home"></i> <span id="shop_0" data-id="0"><?=$sub['title']?></span>
        </dt>
        <?php foreach($sub['menu'] as $menu){ ?>
        <dd class="<?php echo ($action == $menu["action"])?'active':'';?>">
            <a href="<?=$menu['url']?>"><?=$menu['title']?></a>
        </dd>
        <?php } ?>
    </dl>
    <?php } ?>
</div>
<link rel="stylesheet" href="/Static/admin/css/order.css">
<script src="/Static/admin/js/laydate/laydate.js"></script>

<script src="/Static/admin/js/zhongtong.js"></script>
<script src="/Static/admin/js/zhongtong2.js"></script>


<script src="/Static/mobile/js/areadata.js"></script>
<script src="/Static/mobile/js/myarea.js"></script>
<script src="/Static/mobile/js/expressdata.js"></script>

<script language="javascript" src="/Static/admin/js/cainiao/CaiNiaoPrintFuncs.js"></script>

<object id="CaiNiaoPrint_OB" classid="clsid:09896DB8-1189-44B5-BADC-D6DB5286AC57" width=0 height=0> 
	<embed id="CaiNiaoPrint_EM" TYPE="application/x-cainiaoprint" width=0 height=0  ></embed>
</object> 

<object id="CaiNiaoPrint_OB_2" classid="clsid:09896DB8-1189-44B5-BADC-D6DB5286AC57" width=0 height=0> 
  <param name="Caption" value="内嵌显示区域">
  <param name="Border" value="1">
  <param name="Color" value="#C0C0C0">
  <embed id="CaiNiaoPrint_EM_2" TYPE="application/x-cainiaoprint" width=0 height=0>
</object> 

<div class="content-right fl">
	<h1 class="content-right-title">
		订单列表
	</h1>
	<form action="" method="get" id="searchForm">
		<div class="tables-searchbox">
			<input type="text" class="input mini" placeholder="商品名称" name="goods_name" id="goods_name" value="<?php echo get('goods_name');?>">
			<input type="text" placeholder="输入订单号" class="input mini" name="order_id" id="order_id" value="<?php echo get('order_id');?>">

                        <input type="text" placeholder="输入收货人" class="input mini" name="delivery_name" id="delivery_name" value="<?php echo get('delivery_name');?>">
			<input type="text" placeholder="输入手机号" class="input mini" name="delivery_mobile" id="delivery_mobile" value="<?php echo get('delivery_mobile');?>">
			
		</div>
            <div class="tables-searchbox">
			<input type="text" class="input mini" placeholder="下单人ID" name="order_user_id" id="order_user_id" value="<?php echo get('order_user_id');?>">
			<input type="text" class="input mini" placeholder="销售人ID" name="xiaoshou_user_id" id="xiaoshou_user_id" value="<?php echo get('xiaoshou_user_id');?>">
			
                        <input type="text" name="start_create_time" id="start_create_time" value="<?php echo get('start_create_time');?>" placeholder="订单创建起始时间" class="input  newinput">
			<span class="mgr5">至</span> 
			<input type="text" name="end_create_time" id="end_create_time" value="<?php echo get('end_create_time');?>" placeholder="订单创建结束时间" class="input  newinput" > 
                        
                       
		</div>
		<div class="tables-searchbox">
			
                        <input type="text" name="start_send_time" id="start_send_time" value="<?php echo get('start_send_time');?>" placeholder="订单发货起始时间" class="input  newinput">
			<span class="mgr5">至</span> 
			<input type="text" name="end_send_time" id="end_send_time" value="<?php echo get('end_send_time');?>" placeholder="订单发货结束时间" class="input  newinput" > 
                        
		</div>
            
            <div class="tables-searchbox"> 收货地区：
                <select id="province" name="province" style="width:200px;"></select>
                <select id="city" name="city" style="width:200px;"></select>
                <select id="county" name="county" style="width:200px;"></select>
            </div>
            
            
           
				
		<div>
		
			<select name="express" class="select mini" id="express">
				<option value="" <?php echo (get("express") == "") ? "selected" : "";?> >配送方式</option>
				
	<?php foreach($expresscom as $k=>$v){ ?>
	
		<option value="<?php echo $v['ecom_name'];?>" <?php echo (get("express") == $v['ecom_name']) ? "selected" : "";?> ><?php echo $v['ecom_name'];?></option>
	
	<?php } ?>
				
				
				
				
			</select>
			<input type="hidden"  name="status" value="7">
			<input type="text" placeholder="输入快递单号" class="input mini" name="express_no" id="express_no" value="<?php echo get('express_no');?>"> 
			<button  class="btn btn-primary vtal-2">
				<i class="gicon-search white"></i>查询
			</button>
			<a href="/admin/order/index/status/7" class="btn btn-primary vtal-2">清除查询</a>
			<a class="btn btn-success " href="javascript:excel();"><i class="gicon-share white"></i>导出</a>
			
			
			<a class="btn btn-disabled" href="javascript:dayin(1);" ><i class="gicon-share white"></i>打印电子面单</a>
			<a class="btn btn-success " href="javascript:dayin(2);" ><i class="gicon-share white"></i>打印普通快递单</a>
			<span class="btn btn-primary j-add" style="top:10px;"><span id="upload"></span></span>
			
			<a class="btn btn-success" target="_blank" href="http://note.youdao.com/groupshare/?token=BE5C6E3D8F9B4D44A46AC4398937DB6F&gid=10064969"><i class="gicon-share white"></i>如何批量发货</a>
			<a class="btn btn-success " href="javascript:help(2);"><i class="gicon-share white"></i>如何批量打印</a>
			
		</div>
	</form>
	

	<!-- 3.待退款 4已退款,5发货,2完成,0未完成,6订单关闭,1已付款 -->
	<div class="tabs clearfix mgt15 tabs-width order-numbers">
		<a href="/admin/order/index/status/7<?php echo $params;?>" class="<?php echo ($status == 7 && !get('printed'))?'active':'';?> tabs_a fl">全部订单(<?php echo $count[7];?>)</a>
		<a href="/admin/order/index/status/1<?php echo $params;?>" class="<?php echo ($status == 1)?'active':'';?> tabs_a fl order1">待发货(<?php echo $count[1];?>)</a>
		<a href="/admin/order/index/status/0<?php echo $params;?>" class="<?php echo ($status == 0 && $action!='express')?'active':'';?> tabs_a fl order0">待付款(<?php echo $count[0];?>)</a> 
		<a href="/admin/order/index/status/5<?php echo $params;?>" class="<?php echo ($status == 5)?'active':'';?> tabs_a fl order2">已发货(<?php echo $count[5];?>)</a>
		<a href="/admin/order/index/status/2<?php echo $params;?>" class="<?php echo ($status == 2)?'active':'';?> tabs_a fl order3">交易完成(<?php echo $count[2];?>)</a>
		<a href="/admin/order/index/status/6<?php echo $params;?>" class="<?php echo ($status == 6)?'active':'';?> tabs_a fl order4">已关闭(<?php echo $count[6];?>)</a>
		<a href="/admin/order/index/status/3<?php echo $params;?>" class="<?php echo ($status == 3)?'active':'';?> tabs_a fl order3">待退款(<?php echo $count[3];?>)</a>
		<a href="/admin/order/index/status/4<?php echo $params;?>" class="<?php echo ($status == 4)?'active':'';?> tabs_a fl order4">退款完成(<?php echo $count[4];?>)</a>
<!--  
		<a href="/admin/order/index/printed/1<?php echo $params;?>" class="<?php echo (get('printed') == 1)?'active':'';?> tabs_a fl order3">已打印面单(<?php echo $count[9];?>)</a>
		<a href="/admin/order/index/printed/2<?php echo $params;?>" class="<?php echo (get('printed') == 2)?'active':'';?> tabs_a fl order4">未打印面单(<?php echo $count[10];?>)</a>
-->
	</div>
	<!-- end tabs -->

<style>
.goods td{
	border:0px;border-bottom:1px solid #e7e7eb;	
}

.goods tr{
	height:75px;
}

.goods td:last-child{
	border-left:0px;
	border-right:0px;
}

.goods td:first-child{
	border-left:0px;
	border-right:0px;
}

.maingoods{
	min-height:113px;
}

.bigfont{
	font-size:16px;
	font-weight:bold;
}

.red{
	color:#ff0000;
}

.green{
	color:#25c401;
}

.gray{
	color:#999;
}

.yellow{
	color: #db7e05;
}

</style>


	<?php foreach($datalist as $key=>$value){?>

	<table width="100%" class="wxtables table-order mgt10">

		<colgroup>
			<col width="30%">
			<col width="9%">
			<col width="11%">
			<col width="11%">
			<col width="8%">
			<col width="10%">
			<col width="10%">
			<col width="8%">
		</colgroup>

		<thead>
			<tr>
				<td colspan="8" style="background-color:#eee;text-align:left;" >编号:<?php echo $value['order_id']; ?> 
				订单号:<?php echo $value['order_sn']; ?> 下单:<?php echo $value['create_time']; ?> 
				<?php if($value['pay_time']){?>付款:<?php echo $value['pay_time']; } ?> 
				<?php if($value['send_time']){?>发货:<?php echo $value['send_time']; } ?> 
				<?php if($value['shouhuo_time']){?>收货:<?php echo $value['shouhuo_time']; } ?>
				<?php if($value['close_time']){?>关闭时间:<?php echo $value['close_time']; echo $value['is_closebysys'] ? "(超时关闭)":"(用户关闭)"; } ?>
				<?php if($value['refer_uid']){?>推荐人: <?php echo emoji_unified_to_html($value['refer_nickname']); ?> 推荐人ID:<?php echo $value['refer_uid']; } ?>
				<!--<?php if($value['king_uid']){?>皇冠: <?php echo emoji_unified_to_html($value['king_realname']); ?> 皇冠ID:<?php echo $value['king_uid']; } ?>-->
				<?=$value['type_text']?>
                                </td>
			</tr>
		</thead>
		
		<tr bgcolor="#FFFFFF" class="maingoods">
		
			<td width="3%" style="padding:0px;" >
			<table width="100%" cellpadding="0" cellspacing="0" class="goods">
			
					<?php if($value['goods']){ foreach($value['goods'] as $kk=>$val){ ?>
					<tr>
						<td width="15%" align="center"><img src="<?php echo C('UPYUN_DOMAIN').$val['goods_pic']; ?>!headimgurl" onerror="javascript:this.src='/Static/admin/images/error.png';" width="60" height="60"></td>
						<td width="35%" align="left"><?php echo $val['goods_name'] ?> <?php echo $val['guige_name'] ? '【'.$val['guige_name'].'】' : '';?></td>
						<td width="15%" align="center">单价<br /><?php echo $val['shop_price']; ?></td>
						<td width="20%" align="center">数量<br /><?php echo $val['num']; ?></td>
						<td width="15%" align="center">小计<br /><?php echo number_format($val['shop_price']*$val['num'], 2, '.', ''); ?></td>
					</tr>

					<?php  } }else{ ?>
								<tr>
									<td width="15%" align="center"><img src="" onerror="javascript:this.src='/Static/admin/images/error.png';" width="60" height="60"></td>
									<td width="35%" align="left"><?=$value['order_title']?></td>
									<td width="15%" align="center">单价<br /><?php echo $value['all_money']; ?></td>
									<td width="20%" align="center">数量<br />1</td>
									<td width="15%" align="center">小计<br /><?php echo $value['all_money']; ?></td>
								</tr>


									<?php  } ?>
			</table>
			</td>
			


<td>

<?php if($value['pay_money']>0){ ?>
<?=$value['pay_typename']?>: <span class="green">&yen;<?php echo $value['pay_money']; ?></span><br>
<?php } ?>

<?php if($value['yongjin_money']>0){ ?>
<?php echo C("YONGJIN_NAME");?>支付: <span class="green">&yen;<?php echo $value['yongjin_money']; ?></span><br>
<?php } ?>

<?php if($value['score_money']>0){ ?>
<?php echo C("SCORE_NAME");?>支付: <span class="green">&yen;<?php echo $value['score_money']; ?></span><br>
<?php } ?>


<?php if($value['cash_money']>0){ ?>
<?php echo C("CASH_NAME");?>支付: <span class="green">&yen;<?php echo $value['cash_money']; ?></span><br>
<?php } ?>


<?php if($value['tihuo_money']>0){ ?>
<?php echo C("TIHUO_NAME");?>支付: <span class="green">&yen;<?php echo $value['tihuo_money']; ?></span><br>
<?php } ?>


<!--<?php if($value['prize_money']>0){ ?>
奖励佣金支付: <span class="green">&yen;<?php echo $value['prize_money']; ?></span><br>
<?php } ?>-->

</td>

			<td>
			商品:+&yen;<?php echo $value['order_cashmoney']; ?>
                        <?php if($value['bzj_money']>0){ ?>
                        <br>保证金: +&yen;<?php echo $value['bzj_money']; ?>
                        <?php } ?>
                        
                        <?php if($value['pxf_money']>0){ ?>
                        <br>培训费: +&yen;<?php echo $value['pxf_money']; ?>
                        <?php } ?>
                        
			<br>运费: +&yen;<?php echo $value['shipping']; ?>
			<br>折扣: -&yen;<?php echo $value['zhekou_money']; ?>

			
			</td>
			
			<td>
			
<?php echo emoji_unified_to_html($value['nickname']); ?>

(<a style="color:blue;" href="/admin/order/index/status/7?order_user_id=<?php echo $value['uid']; ?>">编号: <?php echo $value['uid']; ?></a>)




			</td>
			
			<td>
			<span class="bigfont"><?php echo $value['ostatus3'];?></span>
			</td>
			
			<td>
				<span class="red bigfont"><?php echo price_format($value['pay_orgmoney']+$value['shipping']); ?></span>
			</td>
			<?php if($admininfo['role_id']!=58){ ?>
			<td>
			<span style="font-size:16px"><?php echo $value['goods']?$value['ostatus']:'';?></span>
                        <?php if($value['checked']==0 && $admininfo['role_id'] != 2 && $admininfo['role_id']!=54 && $admininfo['role_id']!=59){?>
			<a onclick="changeorder(<?=$value['order_id']?>)" class="btn btn-primary vtal-2" >改为已支付</a>
			<?php  } ?>
			</td>
			
			<td>
			
					
				
					<?php if($value['checked']=='3'){?>
					<?php echo $value['message']; ?>
					<?php } ?>

					<?php if($value['express_no']!=''){?>
					<br>
					<a href="javascript:wuliuajax('<?php echo $value['express']; ?>','<?php echo $value['express_no']; ?>');"><?php echo $value['express']; ?>：<?php echo $value['express_no']; ?></a>
					<?php } ?>
					
					
					<?php if($value['checked']=='1'){?>
					<br>
					<!--<a href="javascript:dadan('<?php echo $value['order_sn'];?>');" class="btn btn-primary vtal-2" style="padding:2px 10px;line-height: 15px;height:15px;" orderid="3956">打单</a>-->
					
					<?php echo $value['print_nums'] ? "已打单".$value['print_nums']."次":"";?>
					<?php } ?>
					
					
				
			</td>
			<?php } ?>
			
			
			
		</tr>



		<tr>
			<td colspan="9" style="text-align:left;">收货信息: 收货人：<?php echo $value['delivery_name']?$value['delivery_name']:$value['realname'];?> <?php if(true){ ?>收货地址：<?php echo $value['delivery']['province']." ".$value['delivery']['city']." ".$value['delivery']['county']." ".$value['delivery']['address']; } ?> &nbsp;&nbsp;&nbsp;&nbsp;联系电话：<?php echo $value['delivery']['delivery_mobile']?$value['delivery']['delivery_mobile']:$value['delivery_mobile'];?> <?php if($value['delivery']['wechat_user']!=''){ ?>微信号:<?php echo $value['delivery']['wechat_user']; } ?>
			<?php echo $value['bill_name']?'&nbsp;&nbsp;发票抬头:'.$value['bill_name']:'' ?></td>
		</tr>
		
		<?php if($value['khnote']!=''){ ?>
		<tr>
			<td colspan="9" style="text-align:left;">客户留言: <?php echo $value['khnote']; ?></td>
		</tr>
		<?php } ?>
                
                <?php if($value['sjnote']!=''){ ?>
		<tr>
			<td colspan="9" style="text-align:left;">备注: <?php echo $value['sjnote']; ?></td>
		</tr>
		<?php } ?>

	</table>
	<?php } ?>


	<div class="tables-btmctrl clearfix">
           <div class="mgt10">
               <div class="paginate">
                  <?php echo ($page); ?>
               </div>
           </div>
	</div>


</div>

<script>
    city.getcity('province','city','county','<?php echo $delivery['province'];?>','<?php echo $delivery['city'];?>','<?php echo $delivery['county'];?>',1);

        
var CNPrint; //声明为全局变量 
var FAHUO_ADDRESS = "<?php echo C('FAHUO_ADDRESS');?>";
var FAHUO_CONTACT = "<?php echo C('FAHUO_CONTACT');?>";
var FAHUO_TEL = "<?php echo C('FAHUO_TEL');?>";
var FAHUO_DANWEI = "<?php echo C('FAHUO_DANWEI');?>";
var FAHUO_NOTE = "<?php echo C('FAHUO_NOTE');?>";
var FAHUO_ADS = "<?php echo C('FAHUO_ADS');?>";


function ppp(data,ptype,CNPrint){

	//CNPrint.SET_PRINT_IDENTITY("AppKey="+AppKey+"&Seller_ID="+Seller_ID);
	CNPrint.PRINT_INITA(0,0,400,800,"哇哦科技-<?php echo C("SITE_NAME");?>");
	
	if(ptype == 1){
		CNPrint.SET_PRINT_PAGESIZE(1, 1000,1800,"CreateCustomPage");
	}else if(ptype == 2){
		CNPrint.SET_PRINT_PAGESIZE(1,2300, 1200,"CreateCustomPage");
	}
	
	CNPrint.ADD_PRINT_HTM(0,0,"100%","100%",data);
	CNPrint.PRINT();
	//CNPrint.PRINT();
	//CNPrint.PREVIEW();
	return true;
}


function getdayindata(url,ptype){
	
	
	CNPrint=getCaiNiaoPrint(document.getElementById('CaiNiaoPrint_OB_2'),document.getElementById('CaiNiaoPrint_EM_2')); 

	
    if ((CNPrint==null)||(typeof(CNPrint.VERSION)=="undefined")) {
        //没有安装打印组件
		layer.msg('你是首次打印,请先下载并安装菜鸟打印组件,稍后将指引你下载安装...',{icon: 7}, function(){
			help(2);
		}); 
        return false;
	}
	
	
	
	
	$.ajax({
		url : url,
		type : "GET",
		dataType : 'json',
		success : function(data) {
			
			layer.closeAll('loading');//关闭正在加载
			
			if(data.ret != 0){
				// 失败
				layer.msg(data.msg, {icon: 2});
				return false;
			}
			
			//确认打印操作
			layer.confirm(data.msg, {
			    btn: ['确定打印','我再想想'], //按钮
			    title: "你确定要打印吗?"
			}, function(){
				//进行打印操作
				layer.msg("正在和打印机通信,请稍后", {icon: 1});
				
				//layer.load();//正在加载

				
				
				CNPrint.SELECT_PRINTER();
				
				var i;
				var order_ids = new Array();

				for(i in data.data['dayin']){
					console.log(data.data['dayin'][i]);
					if(ptype == 1){
						//电子面单
						var zt = zthtml(data.data['dayin'][i]);
					}else if(ptype == 2){
						//普通面单
						var zt = zthtml2(data.data['dayin'][i]);
					}
					
					layer.msg("正在打印第"+i+"张,请稍后", {icon: 1});
					
					ppp(zt,ptype,CNPrint);
					
					order_ids[i] =  data.data['dayin'][i]['order_id'];
					
					//layer.closeAll();//关闭
					//return false;
				}
				
				//将订单号设置为已打印状态
				$.ajax({
					url : '/admin/order/dayinnums/',
					type : "POST",
					data : {"order_ids":order_ids},
					dataType : 'json',
					success : function(data) {
						console.log(data);
					}
				});
				
				layer.closeAll();//关闭
				
			}, function(){
				layer.msg('打印操作已取消', {icon: 7});

			});

		},
		beforeSend:function(){
			layer.closeAll();//关闭
			layer.load();//正在加载
       },
       error: function() {
		   layer.closeAll('loading');//关闭正在加载
		   layer.msg("网络错误,请重试", {icon: 2});
       }
       
	});
}

/*
 * 检查浏览器
 */
function  testbbb(){
	var Sys = {};
	var ua = navigator.userAgent.toLowerCase();
	window.ActiveXObject ? Sys.ie = ua.match(/msie ([\d.]+)/)[1] :
	document.getBoxObjectFor ? Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1] :
	window.MessageEvent && !document.getBoxObjectFor ? Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1] :
	window.opera ? Sys.opera = ua.match(/opera.([\d.]+)/)[1] :
	window.openDatabase ? Sys.safari = ua.match(/version\/([\d.]+)/)[1] : 0;

	console.log(Sys);
	
	if(Sys.ie){

		layer.msg('非常抱歉,打印功能不支持ie浏览器,请升级你的浏览器,如你使用360/搜狗等双核浏览器,请切换到极速模式...',{icon: 7}, function(){
			help(2);
		}); 
		
		
		return false;
	}
	
	//以下进行测试
	if(Sys.firefox){
		//火狐
		return true;
	}

	if(Sys.chrome){
		var str1 = Sys.chrome.split(".");
		if(str1[0]>45){
			
			layer.msg('非常抱歉,谷歌浏览器暂时只支持44及44以下版本,请降级谷歌浏览器...',{icon: 7}, function(){
				help(2);
			}); 
			return false;
		}else{
			return true;
		}
	}
	if(Sys.opera){
		return true;
	}
	if(Sys.safari){
		//ok
		return true;
	}
}

function  dadan(order_sn){
	if(!testbbb()){
		return false;
	}
	
	var url = "/admin/order/dayin/?order_sn="+order_sn;
	layer.msg('正在等待打印服务器处理,请耐心等待...', {icon: 16});

	getdayindata(url,2);
}


function dayin(ptype){
	
	if(ptype == 1){
		layer.msg('电子面单服务请先联系快递公司开通电子面单账号', {icon: 7});
		return false;
	}
	
	if(!testbbb()){
		return false;
	}
	
	var order_user_id = $("#order_user_id").val();
	var xiaoshou_user_id = $("#xiaoshou_user_id").val();
	
<!--	var order_sn = $("#order_sn").val();-->
        var order_sn = '';
	var delivery_name = $("#delivery_name").val();
	
	var delivery_mobile = $("#delivery_mobile").val();
	var express = $("#express").val();
	var express_no = $("#express_no").val();

	
	var start_create_time = $("#start_create_time").val();
	var end_create_time = $("#end_create_time").val();

	var url = "/admin/order/dayin/?order_user_id="
			+order_user_id+"&xiaoshou_user_id="+xiaoshou_user_id
			+"&order_sn="+order_sn+"&delivery_name="+delivery_name
			+"&delivery_mobile="+delivery_mobile
			+"&express="+express
			+"&status="+<?php echo get("status");?>
			+"&express_no="+express_no
			+"&start_create_time="+start_create_time+"&end_create_time="+end_create_time;
	layer.msg('正在等待打印服务器处理,请耐心等待...', {icon: 16});
	
	getdayindata(url,ptype);
	
}
function excel(){

	var order_user_id = $("#order_user_id").val();
	var xiaoshou_user_id = $("#xiaoshou_user_id").val();
	
	var order_sn = $("#order_sn").val();
        var order_sn = '';
	var delivery_name = $("#delivery_name").val();
	
	var delivery_mobile = $("#delivery_mobile").val();
	var express = $("#express").val();
	var express_no = $("#express_no").val();

	
	var start_create_time = $("#start_create_time").val();
	var end_create_time = $("#end_create_time").val();
	
	if(!start_create_time){
		layer.msg('你选择要导出的起始时间', {icon: 7});
		return false;
	}

	var url = "/admin/order/orderexcel/?order_user_id="
			+order_user_id+"&xiaoshou_user_id="+xiaoshou_user_id
			+"&order_sn="+order_sn+"&delivery_name="+delivery_name
			+"&delivery_mobile="+delivery_mobile
			+"&express="+express
			+"&status="+<?php echo $_GET['status']?$_GET['status']:'7';?>
			+"&express_no="+express_no
			+"&start_create_time="+start_create_time+"&end_create_time="+end_create_time;
	
	layer.msg('正在导出,请耐心等待...', {icon: 16});
	
	window.location.href = url;
	
}

var start = {
    elem: '#start_create_time',
    format: 'YYYY-MM-DD hh:mm:ss',
    min: '2015-11-01 00:00:00', //设定最小日期
    max: laydate.now(), //最大日期为当前日期
    istime: true,
    istoday: false,
    choose: function(datas){
         end.min = datas; //开始日选好后，重置结束日的最小日期
         end.start = datas //将结束日的初始值设定为开始日
    }
};
var end = {
    elem: '#end_create_time',
    format: 'YYYY-MM-DD hh:mm:ss',
    min: '2015-11-01 00:00:00', //设定最小日期
    max: laydate.now(),
    istime: true,
    istoday: false,
    choose: function(datas){
        start.max = datas; //结束日选好后，重置开始日的最大日期
    }
};
laydate(start);
laydate(end);

var sendstart = {
    elem: '#start_send_time',
    format: 'YYYY-MM-DD hh:mm:ss',
    min: '2015-11-01 00:00:00', //设定最小日期
    max: laydate.now(), //最大日期为当前日期
    istime: true,
    istoday: false,
    choose: function(datas){
         sendend.min = datas; //开始日选好后，重置结束日的最小日期
         sendend.start = datas //将结束日的初始值设定为开始日
    }
};
var sendend = {
    elem: '#end_send_time',
    format: 'YYYY-MM-DD hh:mm:ss',
    min: '2015-11-01 00:00:00', //设定最小日期
    max: laydate.now(),
    istime: true,
    istoday: false,
    choose: function(datas){
        sendstart.max = datas; //结束日选好后，重置开始日的最大日期
    }
};
laydate(sendstart);
laydate(sendend);


$(".ordersend").click(function(){
	  //发货
	var orderid = $(this).attr("orderid");
	var delivery_mobile = $(this).attr("delivery_mobile");
	var delivery_name = $(this).attr("delivery_name");
	fahuo(orderid,delivery_mobile,delivery_name);
});

$(".orderback").click(function(){
	  //退货
	var orderid = $(this).attr("orderid");
	  
	layer.confirm('你确定要同意退款吗？', {
	    btn: ['确定同意','我再想想'], //按钮
	    title: "你确定要退款吗?"
	}, function(){
	    //layer.msg('已退款', {icon: 1});
	    
	    
		layer.confirm('注意:退款操作不可撤销,你真的确定要同意退款吗???', {
		    btn: ['我确定','我再想想'], //按钮
		    title: "你确定要退款吗?"
		}, function(){
			
			
				layer.confirm('重要的事情说三遍:现在要操作退款吗???现在要操作退款吗???现在要操作退款吗???', {
				    btn: ['我确定','我再想想'], //按钮
				    title: "你确定要退款吗?"
				}, function(){
					
					
				    //layer.msg('已退款', {icon: 1});
				    var url = "/admin/order/tuikuan/?order_id="+orderid;
				    AjaxUrl(url);
				    
				    
				}, function(){
					layer.msg('你未同意退款', {icon: 7});
			
				});
		    
		    
		}, function(){
			layer.msg('你未同意退款', {icon: 7});
	
		});
	    

	    
	}, function(){
		layer.msg('你未同意退款', {icon: 7});

	});
});

$(".noorderback").click(function(){
	  //拒绝退货
	var orderid = $(this).attr("orderid");
	alert(orderid);
});



//发货
function fahuo(orderid,delivery_mobile,delivery_name){
	//页面层
	var expresscom = "";
	<?php foreach($expresscom as $k=>$v){ ?>
		expresscom += '<option value="<?php echo $v['ecom_name'];?>"><?php echo $v['ecom_name'];?></option>';
	<?php } ?>
	
	
	
	var content = '<div style="margin:25px;"><p>收货人:'+delivery_name+' 　　　电话:'+delivery_mobile+'</p>'
	+'<br><select name="express_send" id="express_send" class="select mini">'
	+expresscom
	+'</select><input type="text" placeholder="输入快递单号,无则填写无" class="input newinput" name="express_no_send" id="express_no_send" value="">'
	+'<span id="orderid" style="display:none;" orderid="'+orderid+'"></span>'
	+'<a href="javascript:fahuo2();" class="btn btn-primary vtal-2">发货</a></div>';

	layer.open({
		title:"确认发货 收货人"+delivery_name+" 订单ID:"+orderid,
	    type: 1,
	    skin: 'layui-layer-rim', //加上边框
	    area: ['420px', '240px'], //宽高
	    content: content
	});
}


function help(type){
	var txt1 = '<div style="padding:15px;line-height: 25px;"><p>如何批量发货:</p><p>1.点击"待发货"选项卡,点击"导出"按钮,导出需要发货的订单 </p>'+
	'<p>2.在导出的excel表格里,填写物流公司,物流单号<p>'+
	'<p>3.点击"表格批量发货"按钮,选择表格文件上传 <p>'+
	'<p>4.稍等片刻,批量发货完成</p></div>';
	
	var txt2 = '<div style="padding:15px;line-height: 25px;"><p>如何批量打印订单: </p>'+
	'首次打印请先安装菜鸟打印插件,<a href="https://www.taobao.com/market/cainiao/eleprint.php" target="_blank" style="color:blue;"> 点击下载安装打印插件</a>'+
	'<p>批量打印支持的浏览器:<a href="http://file2.mydrivers.com/2015/others/google_chrome_44_0_2403_130.zip" target="_blank" style="color:blue;">谷歌浏览器44及44以下版本</a>,<a href="http://se.360.cn/" target="_blank" style="color:blue;">360浏览器极速模式</a>,<a href="http://www.firefox.com.cn/download/" target="_blank" style="color:blue;">Firefox浏览器</a>等,不支持IE</p>'+
	'<p>1.点击"待发货"选项卡</p>'+
	'<p>2.在"订单创建起始时间"输入框中输入日期<p>'+
	'<p>3.点击"打印普通快递单"按钮 <p>'+
	'<p>4.点击确认打印按钮 </p>'+
	'<p>5.选择打印机,稍等片刻,等待打印完成</p></div>';

	if(type == 1){
		content = txt1;
	}else{
		content = txt2;
	}
	
	layer.open({
		title:"使用帮助",
	    type: 1,
	    skin: 'layui-layer-rim', //加上边框
	    area: ['420px', '300px'], //宽高
	    content: content
	});
	
}


function fahuo2(){
	var express = $("#express_send").val();
	var express_no = $("#express_no_send").val();
	var order_id = $("#orderid").attr("orderid");
	if(!express_no){
		layer.msg("请输入物流单号", {icon: 2});
		return false;
	}
	if(!order_id){
		layer.msg("参数错误", {icon: 2});
		return false;
	}

	$.ajax({
		url : "/admin/order/send",
		type : "POST",
		data : {"order_id":order_id,"express":express,"express_no":express_no},
		dataType : 'json',
		success : function(data) {
			layer.closeAll('loading');//关闭正在加载
			if(data.ret == 0){
				// 成功
				var messagetype = 1;
			}else{
				// 失败
				var messagetype = 2;
			}
			if (data.url) {
				// 如果有跳转地址
				layer.msg(data.msg,{icon: messagetype}, function(){
					window.location.href = data.url;//跳转
				}); 
				
			} else {
				layer.msg(data.msg, {icon: messagetype},function(){
					layer.closeAll();//关闭
					location.reload();
				});
			}
		},
		beforeSend:function(){
			layer.load();//正在加载
       },
       error: function() {
		   layer.closeAll('loading');//关闭正在加载
		   layer.msg("网络错误,请重试", {icon: 2});
       }
       
	});
	
	
	
}


function wuliuajax(express,express_no){

	if(!express_no){
		layer.msg("物流单号为空", {icon: 2});
		return false;
	}

	if(!express){
		layer.msg("物流公司为空", {icon: 2});
		return false;
	}
	
	
	$.ajax({
		url : "/admin/order/wuliuajax",
		type : "POST",
		data : {"express":express,"express_no":express_no},
		dataType : 'json',
		success : function(data) {
			layer.closeAll('loading');//关闭正在加载
			if(data.ret == 0){
				// 成功
				var messagetype = 1;
			}else{
				// 失败
				var messagetype = 2;
			}
			if (data.url) {
				// 如果有跳转地址
				layer.msg(data.msg,{icon: messagetype}, function(){
					window.location.href = data.url;//跳转
				}); 
				
			} else {
				
				layer.closeAll();//关闭
				
				var content = "";
				
				var wuliu_txt = makewuliu(data.data.wuliu_res);
				
				content += wuliu_txt;
				
				layer.open({
					title: "单号: "+express+" "+express_no+" ,物流状态: "+data.data.wuliu_status,
				    type: 1,
				    skin: 'layui-layer-rim', //加上边框
				    area: ['440px', '450px'], //宽高
				    content: content
				});
				
			}
		},
		beforeSend:function(){
			layer.load();//正在加载
       },
       error: function() {
		   layer.closeAll('loading');//关闭正在加载
		   layer.msg("网络错误,请重试", {icon: 2});
       }
       
	});
}


function makewuliu(response) {
	
    var markup = '';

    if (typeof(response) == 'object') {
        for (var i in response) {
        	  
           		var time = response[i].time;
                var content = response[i].content;

                markup += '<p style="padding:10px;">';
                markup += time+'---'+content;
                markup += '</p>';

        }
    }
    
    markup = '<div style="padding:10px;">'+markup+'</div>';
    return markup;
}

</script>
<script type="text/javascript" src="/Static/admin/js/swfupload/swfupload.js" ></script>
<script type="text/javascript" src="/Static/admin/js/swfupload/csv.js" ></script>

<script type="text/javascript">
$(window).load(pageInit);
function pageInit(){
	
  var ext = '表格(*.csv;)';//默认值
  ext = ext.match(/([^\(]+?)\s*\(\s*([^\)]+?)\s*\)/i);
  
  swfu = new SWFUpload({
    flash_url : "/Static/admin/js/swfupload/swfupload.swf",
    prevent_swf_caching : false,//是否缓存SWF文件
    upload_url: '/admin/order/excelfahuo', //上传文件路径
    file_post_name : "imgFile",
    post_params:  {'mychatpath':'goods'},//随文件上传一同向上传接收程序提交的Post数据
    use_query_string : false,//是否用GET方式发送参数
    file_types : ext[2],//文件格式限制
    file_types_description : ext[1],//文件格式描述
    file_size_limit : '2MB',	//文件大小限制
    file_queue_limit:0,//上传队列总数
    file_upload_limit:10,//最多5张
    custom_settings : {
      test : "aaa"
    },
    file_queued_handler : fileQueued,//添加成功
    file_queue_error_handler : fileQueueError,//添加失败
    file_dialog_complete_handler : fileDialogComplete,
    upload_start_handler : uploadStart,//上传开始
    upload_progress_handler : uploadProgress,//上传进度
    upload_error_handler : uploadError,//上传失败
    upload_success_handler : uploadSuccess,//上传成功
    upload_complete_handler : uploadComplete,//上传结束
    button_placeholder_id : "upload",
    button_width: 80,
    button_height: 30,
    button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
    button_cursor: SWFUpload.CURSOR.HAND,
    button_text : '<span class="redText" title="将导出的表格填上物流公司和物流单号后上传表格">表格批量发货</span>',
    button_text_style: ".redText {color:#ffffff;}",
    button_text_left_padding: 5,
    button_text_top_padding: 5,
    debug: false
  });
}

function changeorder(id){
	var title = "请注意,你正在修改订单状态,修改后无法撤消";
	layer.confirm(title, {
	    btn: ['确定','我再想想'] //按钮
	}, function(){
		var url = '/admin/order/changeorder?id=' + id;
		AjaxUrl(url);
	}, function(){
		layer.msg('你取消了提交', {icon: 7});
	});
}


</script>
		</div>
	</div>
<!--gonggao-->
<div class="footer">&copy; <?php echo date("Y");?> <?php echo C("SITE_NAME");?> , Inc. All rights reserved.</div>
<a href="#" id="j-gotop" class="gotop" title="回到顶部" style="right:45px; display: inline;"></a>
<script type="text/javascript">
$(function(){
    var height1=$(".content-right").height();
    var height2=$(".content-left").height();
    if(parseInt(height1) < parseInt(height2)){
        $(".content-right").css({'min-height': height2});
    }
    $(window).scroll(function() {
		$(this).scrollTop() >= 150 ? $("#j-gotop").fadeIn(300) : $("#j-gotop").fadeOut(300)
	});
});
</script>
</body>
</html>